package com.example.pixelyear.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.pixelyear.Interface.OnPixelClickListener
import com.example.pixelyear.R
import com.example.pixelyear.bean.YearBean
import com.example.pixelyear.utils.extension.setOnDoubleClickListener
import kotlinx.android.synthetic.main.item_year_view.view.*

class YearViewAdapter(val context: Context) : BaseAdapter<YearBean>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
        return BaseViewHolder(
            LayoutInflater.from(context).inflate(R.layout.item_year_view, parent, false)
        )
    }

    override fun onBindView(itemView: View, bean: YearBean, position: Int) {
        itemView.YearView_Month.text = "${bean.month}月"
        itemView.YearView_Pixel.updateMonthAndYear(bean.month, bean.year)
        itemView.YearView_Pixel.updateDateList(bean.list)
        itemView.setOnDoubleClickListener {
            onItemClick?.click(bean, position)
        }
    }


}
